<template>
  <div class="personal">
    <template v-if="data">
      <!-- 个人信息 -->
      <div class="center">
        <div class="personal-info">
          <div
            class="info-item info1"
            v-for="{ uname, uphone, u_pic, i } in data2"
            :key="i"
          >
            <div class="avatar-wrap headimg">
              <label for="/" class="avatar">
                <!-- <img :src="imgBase + u_pic" /> -->
                <el-image :src="imgBase + u_pic" lazy></el-image>
              </label>
            </div>
            <div class="name">
              {{ uname }}
            </div>
            <div class="tel">
              {{ uphone }}
            </div>

            <div class="link-options">
              <a href="#" class="change-password">修改密码</a>
              <a href="#" class="account-bind">账号绑定</a>
            </div>
          </div>
          <div class="info-item info2">
            <div class="title-box">
              <span class="title">
                <span>我的简历</span>
              </span>
            </div>
            <div class="content-box">
              <div class="resume--resource">
                <div class="resume__header">
                  <div class="resume__title">附件简历</div>
                </div>
                <div class="resume__body">
                  <!-- <p class="resume__name ellipsis">附件简历</p> -->
                  <el-upload
                    class="upload-demo"
                    action="http://localhost:3000/v1/news/upload"
                    :on-change="handleChange"
                    :file-list="fileList"
                    name="uploadFile"
                  >
                    <el-button size="small" type="light" style="border: none"
                      >点击上传</el-button
                    >
                  </el-upload>
                </div>
                <!-- <div class="resume__footer">更新于</div> -->
              </div>
            </div>
          </div>

          <div
            class="info-item info3"
            v-for="{ m_collect, m_send, i } in data1"
            :key="i"
          >
            <div class="info3-box">
              <a href="#">
                <div class="num">{{ m_send }}</div>
                <span>我的投递</span>
              </a>
              <a href="#">
                <div class="num">{{ m_collect }}</div>
                <span>我的收藏</span>
              </a>
            </div>
          </div>
          <div
            class="info-item info4"
            v-for="{ m_nature, m_job, m_position, m_city, i } in data1"
            :key="i"
          >
            <div class="title-box clear-fix">
              <span class="title f1">求职意向</span>
              <a href="#" class="edit-btn f-r">编辑</a>
            </div>
            <div class="info-list">
              <div class="list-item">
                <span class="item-name">求职性质：</span>
                <span>{{ m_nature }}</span>
              </div>
            </div>
            <div class="info-list">
              <div class="list-item">
                <span class="item-name">期望行业：</span>
                <span>{{ m_job }}</span>
              </div>
            </div>
            <div class="info-list">
              <div class="list-item">
                <span class="item-name">期望职位：</span>
                <span>{{ m_position }}</span>
              </div>
            </div>
            <div class="info-list">
              <div class="list-item">
                <span class="item-name">期望城市：</span>
                <span>{{ m_city }}</span>
              </div>
            </div>
          </div>
          <div
            class="info-item info5"
            v-for="{ m_mouth, m_days, m_date, i } in data1"
            :key="i"
          >
            <div class="title-box clear-fix">
              <span class="title f1">求职状态</span>
              <a href="#" class="edit-btn f-r">编辑</a>
            </div>
            <div class="info-list">
              <div class="list-item">
                <span class="item-name">实习时长：</span>
                <span>{{ m_mouth }}</span>
              </div>
            </div>
            <div class="info-list">
              <div class="list-item">
                <span class="item-name">实习天数：</span>
                <span>{{ m_days }}</span>
              </div>
            </div>
            <div class="info-list">
              <div class="list-item">
                <span class="item-name">到岗日期：</span>
                <span>{{ m_date }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- 投递信息 -->
      <div class="management">
        <div class="intern-nav">
          <div
            v-for="(p, i) in job"
            class="intern-nav-item"
            :key="i"
            @click="op = i"
            :class="{ active: op == i }"
          >
            {{ p }}
          </div>
        </div>
        <div class="chat-history-wrap" :class="{ active: op == 0 }">
          <ul>
            <li
              class="item-boss"
              v-for="{
                rid,
                i_hr,
                i_logo,
                i_message,
                i_name,
                i_salary,
                i_title,
                i_req,
                i_picture,
              } in data.slice(0, 4)"
              :key="rid"
            >
              <div class="figure">
                <!-- <img :src="imgBase + i_picture" /> -->
                <el-image :src="imgBase + i_picture" lazy></el-image>
              </div>
              <div class="item-content">
                <div class="info-header">
                  <h3 class="name">
                    {{ i_hr }}
                  </h3>
                </div>
                <div class="info-primary">
                  <div class="company-info">
                    <!-- <img :src="imgBase + i_logo" /> -->
                    <el-image :src="imgBase + i_logo" lazy></el-image>
                    <div class="text">
                      <b>
                        <a href="#">{{ i_name }}</a>
                      </b>
                      <p class="gray">{{ i_message }}</p>
                    </div>
                  </div>
                  <div class="job-info">
                    <div class="job-name">
                      <a href="#">
                        <span class="jobname">{{ i_title }}</span>
                        <span class="salary">{{ i_salary }}</span>
                      </a>
                    </div>
                    <p class="gray">
                      {{ i_req }}
                    </p>
                  </div>
                </div>
              </div>
            </li>
          </ul>
          <div class="pagination-area">
            <div class="options-pages">
              <a href="#" class="flips">上一页</a>
              <a href="#" class="selected">1</a>
              <a href="#" class="flips">下一页</a>
            </div>
          </div>
        </div>
        <div class="chat-history-wrap" :class="{ active: op == 1 }">
          <ul>
            <li
              class="item-boss"
              v-for="{
                rid,
                i_hr,
                i_logo,
                i_message,
                i_name,
                i_salary,
                i_title,
                i_req,
                i_picture,
              } in data.slice(4, 7)"
              :key="rid"
            >
              <div class="figure">
                <!-- <img :src="imgBase + i_picture" /> -->
                <el-image :src="imgBase + i_picture" lazy></el-image>
              </div>
              <div class="item-content">
                <div class="info-header">
                  <h3 class="name">
                    {{ i_hr }}
                  </h3>
                </div>
                <div class="info-primary">
                  <div class="company-info">
                    <!-- <img :src="imgBase + i_logo" /> -->
                    <el-image :src="imgBase + i_logo" lazy></el-image>

                    <div class="text">
                      <b>
                        <a href="#">{{ i_name }}</a>
                      </b>
                      <p class="gray">{{ i_message }}</p>
                    </div>
                  </div>
                  <div class="job-info">
                    <div class="job-name">
                      <a href="#">
                        <span class="jobname">{{ i_title }}</span>
                        <span class="salary">{{ i_salary }}</span>
                      </a>
                    </div>
                    <p class="gray">
                      {{ i_req }}
                    </p>
                  </div>
                </div>
              </div>
            </li>
          </ul>
          <div class="pagination-area">
            <div class="options-pages">
              <a href="#" class="flips">上一页</a>
              <a href="#" class="selected">1</a>
              <a href="#" class="flips">下一页</a>
            </div>
          </div>
        </div>
        <div class="chat-history-wrap" :class="{ active: op == 2 }">
          <ul>
            <li
              class="item-boss"
              v-for="{
                rid,
                i_hr,
                i_logo,
                i_message,
                i_name,
                i_salary,
                i_title,
                i_req,
                i_picture,
              } in data.slice(8, 12)"
              :key="rid"
            >
              <div class="figure">
                <!-- <img :src="imgBase + i_picture" /> -->
                <el-image :src="imgBase + i_picture" lazy></el-image>
              </div>
              <div class="item-content">
                <div class="info-header">
                  <h3 class="name">
                    {{ i_hr }}
                  </h3>
                </div>
                <div class="info-primary">
                  <div class="company-info">
                    <!-- <img :src="imgBase + i_logo" /> -->
                    <el-image :src="imgBase + i_logo" lazy></el-image>

                    <div class="text">
                      <b>
                        <a href="#">{{ i_name }}</a>
                      </b>
                      <p class="gray">{{ i_message }}</p>
                    </div>
                  </div>
                  <div class="job-info">
                    <div class="job-name">
                      <a href="#">
                        <span class="jobname">{{ i_title }}</span>
                        <span class="salary">{{ i_salary }}</span>
                      </a>
                    </div>
                    <p class="gray">
                      {{ i_req }}
                    </p>
                  </div>
                </div>
              </div>
            </li>
          </ul>
          <div class="pagination-area">
            <div class="options-pages">
              <a href="#" class="flips">上一页</a>
              <a href="#" class="selected">1</a>
              <a href="#" class="flips">下一页</a>
            </div>
          </div>
        </div>
        <div class="chat-history-wrap" :class="{ active: op == 3 }">
          <ul>
            <li
              class="item-boss"
              v-for="{
                rid,
                i_hr,
                i_logo,
                i_message,
                i_name,
                i_salary,
                i_title,
                i_req,
                i_picture,
              } in data.slice(13, 16)"
              :key="rid"
            >
              <div class="figure">
                <!-- <img :src="imgBase + i_picture" /> -->
                <el-image :src="imgBase + i_picture" lazy></el-image>
              </div>
              <div class="item-content">
                <div class="info-header">
                  <h3 class="name">
                    {{ i_hr }}
                  </h3>
                </div>
                <div class="info-primary">
                  <div class="company-info">
                    <!-- <img :src="imgBase + i_logo" /> -->
                    <el-image :src="imgBase + i_logo" lazy></el-image>

                    <div class="text">
                      <b>
                        <a href="#">{{ i_name }}</a>
                      </b>
                      <p class="gray">{{ i_message }}</p>
                    </div>
                  </div>
                  <div class="job-info">
                    <div class="job-name">
                      <a href="#">
                        <span class="jobname">{{ i_title }}</span>
                        <span class="salary">{{ i_salary }}</span>
                      </a>
                    </div>
                    <p class="gray">
                      {{ i_req }}
                    </p>
                  </div>
                </div>
              </div>
            </li>
          </ul>
          <div class="pagination-area">
            <div class="options-pages">
              <a href="#" class="flips">上一页</a>
              <a href="#" class="selected">1</a>
              <a href="#" class="flips">下一页</a>
            </div>
          </div>
        </div>
      </div>
    </template>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  computed: {
    ...mapState(["imgBase", "loginuname"]),
  },
  data() {
    return {
      job: ["沟通过", "已投递", "面试", "感兴趣"],
      op: 0,
      data: null,
      data1: null,
      data2: null,
      fileList: [{ name: "", url: "" }],
    };
  },
  props: ["jid"],
  mounted() {
    this.getData();
    this.UNAME();
  },
  methods: {
    getData() {
      const url = "v1/news/resume?uid=" + this.jid;
      // console.log(url);
      this.axios.get(url).then((res) => {
        // console.log(res);
        this.data = res.data.data;
        this.data1 = res.data.data1;
      });
    },
    handleChange(file, fileList) {
      this.fileList = fileList.slice(-3);
      // console.log(fileList);
    },
    // 通过vuex里面存储的用户名获取用户的手机号头像
    UNAME() {
      if (this.loginuname) {
        let url = `v1/users/search?jid=${this.jid}`;
        this.axios.get(url).then((res) => {
          // console.log("ID返回值", this.jid, res);
          this.data2 = res.data.data;
        });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
</style>
<style scoped src="../assets/css/resume.css">
</style>